﻿using System.Text;
using System.Threading.Tasks;
using Windows.Storage;

namespace MicroMVVM.Services.Interfaces
{
    /// <summary>
    /// This interface represents the service to handle storage files.
    /// </summary>
    public interface IStorageFileService
    {
        /// <summary>
        /// Fetches a file from the specified location.
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="storageLocation"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        Task<StorageFile> FetchFileAsync(string filename, StorageLocation storageLocation = StorageLocation.Roaming, string path = "");

        /// <summary>
        /// Checks if a file exists in the specified location.
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="storageLocation"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        Task<bool> FileExistsAsync(string filename, StorageLocation storageLocation = StorageLocation.Roaming, string path = "");

        /// <summary>
        /// Reads the file from the specified location.
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="storageLocation"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        Task<byte[]> ReadAsync(string filename, StorageLocation storageLocation = StorageLocation.Roaming, string path = "");

        /// <summary>
        /// Writes to the specified file in the specified location.
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="content"></param>
        /// <param name="storageLocation"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        Task<bool> WriteAsync(string filename, byte[] content, StorageLocation storageLocation = StorageLocation.Roaming, string path = "");

        /// <summary>
        /// Writes to the specified file in the specified location.
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="content"></param>
        /// <param name="storageLocation"></param>
        /// <param name="path"></param>
        /// <param name="encoding"></param>
        /// <returns></returns>
        Task<bool> WriteAsync(string filename, string content, StorageLocation storageLocation = StorageLocation.Roaming, string path = "", Encoding encoding = null);
    }
}